package com.ccntec.spark.core.tags.form;


import javax.servlet.jsp.JspException;

import com.ccntec.spark.core.BasicTagSupport;

public class FormTag extends BasicTagSupport {
	
	private String name ;
	private String id ;
	private String action ;
	private String method ;
	
	@Override
	public int doStartTag() throws JspException {
		StringBuffer html = new StringBuffer();
		html.append("<form action=\""+action+"\" class=\"form-horizontal\" ");
		if(!isNull(name)){
			html.append("name=\"+name+\" ");
		}
		if(!isNull(id)){
			html.append("id=\"+id+\" ");
		}
		if(!isNull(method)){
			html.append("method=\"+method+\" ");
		}
		html.append(" >");
		outPrint(html);
		return EVAL_BODY_INCLUDE;
	}
	
	@Override
	public int doAfterBody() throws JspException {
		return SKIP_BODY;
	}
	
	@Override
	public int doEndTag() throws JspException {
		StringBuffer html = new StringBuffer();
		html.append("</form>");
		outPrint(html);
		return EVAL_PAGE;
	}
	@Override
	public void release() {
		// TODO Auto-generated method stub
		super.release();
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public void setMethod(String method) {
		this.method = method;
	}
	
}
